﻿//-----------------------------------------------------------------------------------------//
//-     Writen by Raymond Honderdors
//-     2013-05-14
//-
//-     Code can be used as is, no warrenty
//-     https://solutionmanagementki.codeplex.com/
//-----------------------------------------------------------------------------------------//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AnalysisServices;
namespace SMK_SSAS
{
    /// <summary>
    /// 
    /// </summary>
    public class AMO_Database_DatabasePermission
    {
        private Microsoft.AnalysisServices.DatabasePermission amodatabasepermission = null;
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Microsoft.AnalysisServices.DatabasePermission adodbdatasourceview()
        {
            if (amodatabasepermission != null)
            {
                return amodatabasepermission;
            }
            else
            {
                return null;
            }

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Datebase"></param>
        /// <param name="DataSourceID"></param>
        public void SetAMODataSourcePermission(AMO_Database Datebase, string DataSourceID)
        {

            if (Datebase != null)
            {
                AMO_Server Server = Datebase.AMOServer();
                if (Server.Isconnected())
                {
                    if (Datebase.amodatabase().DatabasePermissions.Contains(DataSourceID))
                    {
                        amodatabasepermission = Datebase.amodatabase().DatabasePermissions.Find(DataSourceID);
                    }
                }
            }
        }

    }    
}
